var express = require('express');
var router = express.Router();
let { pool } = require("../config/mysql_config");
// 获取信息
router.get('/list', function (req, res, next) {
  let params = req.query;
  let sqlparam = [params.token];
  let sql = 'SELECT * from user;'
  let resObj;
  pool.query(sql, sqlparam, function (err, rows) {
    if (err) {
      throw err;
    } else {
      if (rows.length > 0) {
        resObj = {
          code: 20000,
          message: 'success',
          data: rows
        }
      } else {
        resObj = {
          code: 20001,
          message: 'fail'
        }
      }
      res.json(resObj);
    }
  })
})

module.exports = router;
